<template>
  <common-select
    :options="projectOptions"
    :defaultValue="defaultProjectIds"
    @changeoption="changeOption"
    :allow-clear="false"
    :show-search="true"
    :disabled="disabled"
    :mode="mode"
  ></common-select>
</template>
<script>
// 项目下拉数据
import CommonSelect from '@/components/SelfComponents/CommonSelect.vue'
import { mapState } from 'vuex'
export default {
  components: {
    CommonSelect
  },
  props: {
    defaultProjectIds: {
      type: [Array, Object],
      default () {
        return []
      }
    },
    disabled: {
      type: Boolean,
      default: false
    },
    mode: {
      type: String,
      default: 'multiple'
    }
  },
  computed: {
    ...mapState({
      projectOptions: (state) => state.project.projectAllData
    })
  },
  data () {
    return {
    }
  },
  watch: {
    time: {
      handler () {
        this.projectOptions.length === 0 && this.getData()
      },
      immediate: true
    }
  },
  created () {
  },
  methods: {
    getData () {
      this.$store.dispatch('getProjectAllData')
    },
    changeOption (val) {
      this.$emit('changeoption', val)
    }
  }
}
</script>
